home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / dist / fw_qt3.idb / usr / freeware / Qt / include / qttableview.h.z / qttableview.h
C/C++ Source or Header  |  2002-04-08  |  7KB  |  252 lines

  1. /**********************************************************************
  2. ** $Id:  qt/qttableview.h   3.0.3   edited Oct 12 12:18 $
  3. **
  4. ** Definition of QtTableView class
  5. **
  6. ** Created : 941115
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file contains a class moved out of the Qt GUI Toolkit API. It
  11. ** may be used, distributed and modified without limitation.
  12. **
  13. **********************************************************************/
  14.  
  15. #ifndef QTTABLEVIEW_H
  16. #define QTTABLEVIEW_H
  17.  
  18. #ifndef QT_H
  19. #include "qframe.h"
  20. #endif // QT_H
  21.  
  22. #ifndef QT_NO_QTTABLEVIEW
  23.  
  24. class QScrollBar;
  25. class QCornerSquare;
  26.  
  27.  
  28. class QtTableView : public QFrame
  29. {
  30.     Q_OBJECT
  31. public:
  32.     virtual void setBackgroundColor( const QColor & );
  33.     virtual void setPalette( const QPalette & );
  34.     void    show();
  35.  
  36.     void    repaint( bool erase=TRUE );
  37.     void    repaint( int x, int y, int w, int h, bool erase=TRUE );
  38.     void    repaint( const QRect &, bool erase=TRUE );
  39.  
  40. protected:
  41.     QtTableView( QWidget *parent=0, const char *name=0, WFlags f=0 );
  42.    ~QtTableView();
  43.  
  44.     int        numRows()    const;
  45.     virtual void setNumRows( int );
  46.     int        numCols()    const;
  47.     virtual void setNumCols( int );
  48.  
  49.     int        topCell()    const;
  50.     virtual void setTopCell( int row );
  51.     int        leftCell()    const;
  52.     virtual void setLeftCell( int col );
  53.     virtual void setTopLeftCell( int row, int col );
  54.  
  55.     int        xOffset()    const;
  56.     virtual void setXOffset( int );
  57.     int        yOffset()    const;
  58.     virtual void setYOffset( int );
  59.     virtual void setOffset( int x, int y, bool updateScrBars = TRUE );
  60.  
  61.     virtual int cellWidth( int col );
  62.     virtual int cellHeight( int row );
  63.     int        cellWidth()    const;
  64.     int        cellHeight()    const;
  65.     virtual void setCellWidth( int );
  66.     virtual void setCellHeight( int );
  67.  
  68.     virtual int totalWidth();
  69.     virtual int totalHeight();
  70.  
  71.     uint    tableFlags()    const;
  72.     bool    testTableFlags( uint f ) const;
  73.     virtual void setTableFlags( uint f );
  74.     void    clearTableFlags( uint f = ~0 );
  75.  
  76.     bool    autoUpdate()     const;
  77.     virtual void setAutoUpdate( bool );
  78.  
  79.     void    updateCell( int row, int column, bool erase=TRUE );
  80.  
  81.     QRect    cellUpdateRect() const;
  82.     QRect    viewRect()     const;
  83.  
  84.     int        lastRowVisible() const;
  85.     int        lastColVisible() const;
  86.  
  87.     bool    rowIsVisible( int row ) const;
  88.     bool    colIsVisible( int col ) const;
  89.  
  90.     QScrollBar *verticalScrollBar() const;
  91.     QScrollBar *horizontalScrollBar() const;
  92.  
  93. private slots:
  94.     void    horSbValue( int );
  95.     void    horSbSliding( int );
  96.     void    horSbSlidingDone();
  97.     void    verSbValue( int );
  98.     void    verSbSliding( int );
  99.     void    verSbSlidingDone();
  100.  
  101. protected:
  102.     virtual void paintCell( QPainter *, int row, int col ) = 0;
  103.     virtual void setupPainter( QPainter * );
  104.  
  105.     void    paintEvent( QPaintEvent * );
  106.     void    resizeEvent( QResizeEvent * );
  107.  
  108.     int        findRow( int yPos ) const;
  109.     int        findCol( int xPos ) const;
  110.  
  111.     bool    rowYPos( int row, int *yPos ) const;
  112.     bool    colXPos( int col, int *xPos ) const;
  113.  
  114.     int        maxXOffset();
  115.     int        maxYOffset();
  116.     int        maxColOffset();
  117.     int        maxRowOffset();
  118.  
  119.     int        minViewX()    const;
  120.     int        minViewY()    const;
  121.     int        maxViewX()    const;
  122.     int        maxViewY()    const;
  123.     int        viewWidth()    const;
  124.     int        viewHeight()    const;
  125.  
  126.     void    scroll( int xPixels, int yPixels );
  127.     void    updateScrollBars();
  128.     void    updateTableSize();
  129.  
  130. private:
  131.     void    coverCornerSquare( bool );
  132.     void    snapToGrid( bool horizontal, bool vertical );
  133.     virtual void    setHorScrollBar( bool on, bool update = TRUE );
  134.     virtual void    setVerScrollBar( bool on, bool update = TRUE );
  135.     void    updateView();
  136.     int        findRawRow( int yPos, int *cellMaxY, int *cellMinY = 0,
  137.                 bool goOutsideView = FALSE ) const;
  138.     int        findRawCol( int xPos, int *cellMaxX, int *cellMinX = 0,
  139.                 bool goOutsideView = FALSE ) const;
  140.     int        maxColsVisible() const;
  141.  
  142.     void    updateScrollBars( uint );
  143.     void    updateFrameSize();
  144.  
  145.     void    doAutoScrollBars();
  146.     void    showOrHideScrollBars();
  147.  
  148.     int        nRows;
  149.     int        nCols;
  150.     int        xOffs, yOffs;
  151.     int        xCellOffs, yCellOffs;
  152.     short    xCellDelta, yCellDelta;
  153.     short    cellH, cellW;
  154.  
  155.     uint    eraseInPaint        : 1;
  156.     uint    verSliding        : 1;
  157.     uint    verSnappingOff        : 1;
  158.     uint    horSliding        : 1;
  159.     uint    horSnappingOff        : 1;
  160.     uint    coveringCornerSquare    : 1;
  161.     uint    sbDirty            : 8;
  162.     uint    inSbUpdate        : 1;
  163.  
  164.     uint    tFlags;
  165.     QRect    cellUpdateR;
  166.  
  167.     QScrollBar *vScrollBar;
  168.     QScrollBar *hScrollBar;
  169.     QCornerSquare *cornerSquare;
  170.  
  171. private:    // Disabled copy constructor and operator=
  172. #if defined(Q_DISABLE_COPY)
  173.     QtTableView( const QtTableView & );
  174.     QtTableView &operator=( const QtTableView & );
  175. #endif
  176. };
  177.  
  178.  
  179. const uint Tbl_vScrollBar    = 0x00000001;
  180. const uint Tbl_hScrollBar    = 0x00000002;
  181. const uint Tbl_autoVScrollBar    = 0x00000004;
  182. const uint Tbl_autoHScrollBar    = 0x00000008;
  183. const uint Tbl_autoScrollBars    = 0x0000000C;
  184.  
  185. const uint Tbl_clipCellPainting = 0x00000100;
  186. const uint Tbl_cutCellsV    = 0x00000200;
  187. const uint Tbl_cutCellsH    = 0x00000400;
  188. const uint Tbl_cutCells        = 0x00000600;
  189.  
  190. const uint Tbl_scrollLastHCell    = 0x00000800;
  191. const uint Tbl_scrollLastVCell    = 0x00001000;
  192. const uint Tbl_scrollLastCell    = 0x00001800;
  193.  
  194. const uint Tbl_smoothHScrolling = 0x00002000;
  195. const uint Tbl_smoothVScrolling = 0x00004000;
  196. const uint Tbl_smoothScrolling    = 0x00006000;
  197.  
  198. const uint Tbl_snapToHGrid    = 0x00008000;
  199. const uint Tbl_snapToVGrid    = 0x00010000;
  200. const uint Tbl_snapToGrid    = 0x00018000;
  201.  
  202.  
  203. inline int QtTableView::numRows() const
  204. { return nRows; }
  205.  
  206. inline int QtTableView::numCols() const
  207. { return nCols; }
  208.  
  209. inline int QtTableView::topCell() const
  210. { return yCellOffs; }
  211.  
  212. inline int QtTableView::leftCell() const
  213. { return xCellOffs; }
  214.  
  215. inline int QtTableView::xOffset() const
  216. { return xOffs; }
  217.  
  218. inline int QtTableView::yOffset() const
  219. { return yOffs; }
  220.  
  221. inline int QtTableView::cellHeight() const
  222. { return cellH; }
  223.  
  224. inline int QtTableView::cellWidth() const
  225. { return cellW; }
  226.  
  227. inline uint QtTableView::tableFlags() const
  228. { return tFlags; }
  229.  
  230. inline bool QtTableView::testTableFlags( uint f ) const
  231. { return (tFlags & f) != 0; }
  232.  
  233. inline QRect QtTableView::cellUpdateRect() const
  234. { return cellUpdateR; }
  235.  
  236. inline bool QtTableView::autoUpdate() const
  237. { return isUpdatesEnabled(); }
  238.  
  239. inline void QtTableView::repaint( bool erase )
  240. { repaint( 0, 0, width(), height(), erase ); }
  241.  
  242. inline void QtTableView::repaint( const QRect &r, bool erase )
  243. { repaint( r.x(), r.y(), r.width(), r.height(), erase ); }
  244.  
  245. inline void QtTableView::updateScrollBars()
  246. { updateScrollBars( 0 ); }
  247.  
  248.  
  249. #endif // QT_NO_QTTABLEVIEW
  250.  
  251. #endif // QTTABLEVIEW_H
  252.